# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libreswan
pkgver=3.32
pkgrel=0
pkgdesc="IPsec implementation for Linux"
url="https://libreswan.org"
arch="all"
license="GPL-2.0-or-later"
depends="nss-tools iproute2"
provides="openswan"
makedepends="bison flex coreutils bash xmlto
	gmp-dev linux-pam-dev nss-dev unbound-dev libcap-ng-dev
	curl-dev nspr-dev bsd-compat-headers ldns-dev
	"
subpackages="$pkgname-doc $pkgname-openrc"
source="https://download.libreswan.org/libreswan-$pkgver.tar.gz
	fix-includes.patch

	Makefile.inc.local"

# secfixes:
#   3.32-r0:
#     - CVE-2020-1763
#   3.29-r0:
#     - CVE-2019-10155
#   3.28-r0:
#     - CVE-2019-12312

build() {
	cp $srcdir/Makefile.inc.local $builddir
	make WERROR_CFLAGS="" \
		INC_RCDEFAULT=/etc/init.d \
		INC_USRLOCAL=/usr \
		FINALBINDIR=/usr/libexec/ipsec \
		FINALLIBEXECDIR=/usr/libexec/ipsec \
		programs
}

package() {
	make INC_MANDIR=share/man \
		INC_RCDEFAULT=/etc/init.d \
		INC_USRLOCAL=/usr \
		DESTDIR="$pkgdir" \
		INSTCONFFLAGS=-m644 \
		FINALBINDIR=/usr/libexec/ipsec \
		FINALLIBEXECDIR=/usr/libexec/ipsec \
		install
}
sha512sums="bb65512351059e2fac6f1c3ed1e291eabd6835faacf6d9c58649dd71dab1bb4fe6d6074178dea6dea01f24d39f3fbefd84c6060e4d8436b5d057fa55ae4467f3  libreswan-3.32.tar.gz
df503e349661a029f8f6569ea65b4ecceb67f18c0a133d4818d390c0e6e719c2c793c483881778685f1eedaa210ea815ae4f77a94fa84a1acb63a9ad5e8db501  fix-includes.patch
36415fae9b6674d66b7728fbc1df4bb3c4fcb16f0bbe88ead1f23e553bb51a9deb288a8659a0050a3fb1e14c3dbb8fb8524e9ef48fb6842dc94b11b758349c58  Makefile.inc.local"
